//
// GPSMapEdit
// (c) Konstantin Galichsky (kg@geopainting.com), 2002-2006
//
// 'Postal address items' dialog.
//

# include "StdAfx.h"
# include "Resource.h"
# include "PAItems.h"
# include "Map.h"
# include "GarminTypes.h"
# include "NavitelTypes.h"
# include "RussaTypes.h"
# include "Globals.h"

const char * OutputPAString (const string_t & _str) {
	return _str.empty () ? "-" : _str.c_str ();
}

void ShowPostalAddressItems () {
	bool bEnableZipCodes, bEnableHighways;
	bool bRegionsEmpty, bCitiesEmpty;
	{
		CCritSec::CLock lock (g_cs);

		bEnableZipCodes = (g_map.pTypeSet == & g_tsGarmin) || (g_map.pTypeSet == & g_tsNavitel) || (g_map.pTypeSet == & g_tsRussa);
		bEnableHighways = g_map.pTypeSet == & g_tsGarmin;

		bRegionsEmpty = g_map.Regions.empty ();
		bCitiesEmpty  = g_map.Cities.empty ();
	}

	CPropertyPages pp;
	size_t cPage = 0;

	// Countries.
	pp.AddPage (new CCountriesPage);
	++ cPage;

	// Regions.
	pp.AddPage (new CRegionsPage);
	++ cPage;

	// Cities.
	const size_t cStartPage = bRegionsEmpty ? 0 : (bCitiesEmpty ? 1 : cPage);
	pp.AddPage (new CCitiesPage);
	++ cPage;

	// Zip codes.
	if (bEnableZipCodes) {
		pp.AddPage (new CZipsPage);
		++ cPage;
	}

	// Highways.
	if (bEnableHighways) {
		pp.AddPage (new CHighwaysPage);
		++ cPage;
	}

	pp.ShowModal (g_hWnd, IDS_PAI_TITLE, cStartPage);
}

